package qfpay

import (
    "fmt"
	//"time"
	//"errors"
	//"thirdpaysdk/core"
	//"thirdpaysdk/utils/pay"
	//"github.com/astaxie/beego"
)
type RspHeader struct {
	StatusCode int      `json:"status_code"`
	Message    string   `json:"message"`
	Success    bool     `json:"success,omitempty"`
}
type PayInfo struct {
	TimeStamp string `json:"timeStamp"`
	PrepayId  string `json:"prepay_id"`
	NonceStr  string `json:"nonceStr"`
	PaySign   string `json:"paySign"`
	OrderNo   string `json:"order_no"`
}

type MicroAppPayResponse struct {
	RspHeader  *RspHeader `json:"meta,omitempty"`
	PayInfo    *PayInfo   `json:"data,omitempty"`
}

func  MicroAppPay()(rsp *MicroAppPayResponse, err error){
	
	merchanNo := "WC5c05ee8d44b1b"
	appsecret := ""
	var reqParams map[string]interface{}
	reqParams = make(map[string]interface{})
	
	reqParams["merchant_no"] = merchanNo
	reqParams["openid"] = "oElDu0FSwHPb9UVRlh9UMiORjZ1Y"
	reqParams["currency"] = "HKD"
	reqParams["amount"] = "1"
	reqParams["product_info"] = "测试商品"
	//reqParams["agent_order_id"] = ""
	//reqParams["notify_url"] = ""
	reqParams["appid"] = "wx82bd84ec09fed74e"
	
	reqURL := "https://openapi-test.qfpay.com/trade/v1/payment"
	sdk := NewSDK(reqURL, merchanNo, appsecret)
	respMap, err := sdk.Execute(reqParams)
	fmt.Println("err", err)
	fmt.Println("respMap", respMap)
	return
}

